package com.dayaokeji.rhythmschoolstudent.callback;

import android.graphics.Matrix;
import android.graphics.RectF;
import android.os.Parcelable;
import android.support.v4.app.SharedElementCallback;
import android.view.View;

/**
 * Created by Gorden on 2017/9/23.
 * 取消转场动画快照，防止OOM
 */

public class SharedElementCallback2 extends SharedElementCallback {

    private boolean isCaptureSnapshot;

    public SharedElementCallback2() {
        this(false);
    }

    public SharedElementCallback2(boolean isCaptureSnapshot) {
        this.isCaptureSnapshot = isCaptureSnapshot;
    }

    @Override
    public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) {
        return isCaptureSnapshot ? super.onCaptureSharedElementSnapshot(sharedElement, viewToGlobalMatrix, screenBounds):null;
    }
}
